#ifndef _VBE_
#define _VBE_

#include <type.h>
/* SuperVGA information block */
struct vbeinfo
{
    char    VESASignature[4];       /* 'VESA' 4 byte signature          */
    short   VESAVersion;            /* VBE version number               */
    char    *OEMStringPtr;      /* Pointer to OEM string            */
    long    Capabilities;           /* Capabilities of video card       */
    unsigned *VideoModePtr;     /* Pointer to supported modes       */
    short   TotalMemory;            /* Number of 64kb memory blocks     */
	u16 oemver;
	char *vendorname;
	char *productname;
	char *productrevision;
	u16 vbeafver;
	unsigned *accelmodes;
	u8 vbe[216];
	u8 oemscratch[256];
}__attribute__((packed));

/* SuperVGA mode information block */
struct vbemodeinfo
{
    u16 ModeAttributes;      /* Mode attributes                 */
    u8  WinAAttributes;      /* Window A attributes             */
    u8  WinBAttributes;      /* Window B attributes             */
    u16 WinGranularity;      /* Window granularity in k         */
    u16 WinSize;             /* Window size in k                */
    u16 WinASegment;         /* Window A segment                */
    u16 WinBSegment;         /* Window B segment                */
    void (*WinFuncPtr)(void);       /* Pointer to window function      */
    u16 BytesPerScanLine;    /* Bytes per scanline              */
    u16 XResolution;         /* Horizontal resolution           */
    u16 YResolution;         /* Vertical resolution             */
    u8  XCharSize;           /* Character cell width            */
    u8  YCharSize;           /* Character cell height           */
    u8  NumberOfPlanes;      /* Number of memory planes         */
    u8  BitsPerPixel;        /* Bits per pixel                  */
    u8  NumberOfBanks;       /* Number of CGA style banks       */
    u8  MemoryModel;         /* Memory model type               */
    u8  BankSize;            /* Size of CGA style banks         */
    u8  NumberOfImagePages;  /* Number of images pages          */
    u8  res1;                /* Reserved                        */
    u8  RedMaskSize;         /* Size of direct color red mask   */
    u8  RedFieldPosition;    /* Bit posn of lsb of red mask     */
    u8  GreenMaskSize;       /* Size of direct color green mask */
    u8  GreenFieldPosition;  /* Bit posn of lsb of green mask   */
    u8  BlueMaskSize;        /* Size of direct color blue mask  */
    u8  BlueFieldPosition;   /* Bit posn of lsb of blue mask    */
    u8  RsvdMaskSize;        /* Size of direct color res mask   */
    u8  RsvdFieldPosition;   /* Bit posn of lsb of res mask     */
    u8  DirectColorModeInfo; /* Direct color mode attributes    */
    u32 phys_base;
    u32 offscreen_start;
    u16 offscreen_memory;
    u16 bytesperscanlin;
    u8 n_image_banked;
    u8 n_image_linear;
    u8 lin_red_mask;
    u8 lin_red_mask_shift;
    u8 lin_green_mask;
    u8 lin_green_mask_shift;
    u8 lin_blue_mask;
    u8 lin_blue_mask_shift;
    u8 lin_res_mask;
    u8 lin_res_mask_shift;
    u32 max_pixel_clock;
    u8 reserved[190];    
} __attribute__((packed));

#define GETMODE 0
#define GETMODEINFO 1
#define GETVBEINFO 2

typedef struct	{
	int (*getVbeInfo)();
	int (*getModeInfo)(int mode);
	int (*getVBEMode)(void);
	void (*putpixel)(u32 x,u32 y,u32 color);
	u32 (*getpixel)(u32 x,u32 y);
	void (*putlfb)(u32 x,u32 y,u32 color);
	u32 (*getlfb)(u32 x,u32 y);
	u32 (*find_graphics_mode)(u32 x,u32 y,u8 bpp);
	int (*is_lfb)();
	u32 (*init_mode)(u32 mode);
	struct vbemodeinfo *ModeInfoBlock;
	struct vbeinfo *VbeInfoBlock;
	u8 *phys_base;
}vbedev;

#endif
